<?

class user_base_peer
{
	const TABLE = 'users';

	public static function get( $id )
	{
		return self::get_by('id', $id);
	}

	public static function get_by($name, $value)
	{
		return db_mysql::get_row(array($name => $value), self::TABLE);
	}

	public static function get_list($params  = array())
	{
		return db_mysql::get_cols($params, self::TABLE);
	}

	public static function insert( array $data )
	{
		$s = db_mysql::insert( $data, self::TABLE );
		return db_mysql::last_id();
	}

	public static function save( $id, array $data )
	{
		return db_mysql::update( $data, array('id' => $id), self::TABLE );
	}

	public static function delete( $id )
	{
		return db_mysql::delete( array('id' => $id), self::TABLE, true );
	}
}